<?php
$id = $_GET["uid"];
$status = $_GET["status"];

 //connect to the DB 
 $db = mysql_connect("mysql513.in.shared-server.net:16033", "JRtu434", "qvoiceDB1");
 mysql_select_db("JRtu434", $db);
 //update the ghostmonitor table with the new status and time
 mysql_query("Update ghostmonitors Set status =\"$status\" where ID=\"$id\"");
 mysql_query("Update ghostmonitors Set endtime=\"".time()."\" where ID=$id");
 $sql = "select $status,key1,key2,key1value,key2value from ghostprojects,ghostmonitors where ghostmonitors.id=\"$id\" and ghostmonitors.gainid=ghostprojects.id";
 $res = mysql_query($sql);
 $item = mysql_fetch_array($res);
 if ($item !== false){
	$forward = $item[0];
	$key1 = $item[1];
	$key2 = $item[2];
	$key1value = $item[3];
	$key2value = $item[4];
 }
$myURL = parse_url($forward);
parse_str($myURL["query"],$query);
$queryString;
	foreach ($query as $key => $value) {
		if (strlen($queryString)>1)
			$queryString .="&";
		
		if($key == $key1)
			$queryString .= $key ."=".$key1value;
		elseif ($key == $key2)
			$queryString .=$key."=".$key2value;
		else
			$queryString .=$key."=".$value;
	}
header("Location: " .$myURL["scheme"]."://".$myURL["host"].$myURL["path"]."?".$queryString);

?>
<html>
	<head>
		
	</head>
	<body>
		
	</body>
</html>